const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = {
  entry: "./src/main.ts",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "main.js",
  },
  devServer: {
    static: "./dist",
    open: false,
  },
  resolve: {
    "extensions": ['.ts','.js','.json']
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"],
        exclude: [
          path.resolve(__dirname,'src/components')
        ]
      },
      {
        test: /\.css$/,
        use: ["style-loader", {
          loader: 'css-loader',
          options: {
            modules: true  
          }
        }],
        include: [
          path.resolve(__dirname,'src/components')
        ]
      },
      {
        test: /\.ts$/,
        use: ["ts-loader"],
        exclude: /node_modules/
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: "./src/index.html",
    }),
    new CleanWebpackPlugin(),
  ],
  mode: "development",
};
